package cn.laike.modules.dev.controller;

import java.util.Arrays;
import java.util.Map;

import cn.laike.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.laike.modules.dev.entity.MemberEntity;
import cn.laike.modules.dev.entity.WithdrawalLogEntity;
import cn.laike.modules.dev.service.WithdrawalLogService;
import cn.laike.common.utils.PageUtils;
import cn.laike.common.utils.R;



/**
 * 提现记录
 *
 * @author ziye
 * @email 524748907@qq.com
 * @date 2019-03-26 17:07:15
 */
@RestController
@RequestMapping("dev/withdrawallog")
public class WithdrawalLogController {
    @Autowired
    private WithdrawalLogService withdrawalLogService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("dev:withdrawallog:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = withdrawalLogService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("dev:withdrawallog:info")
    public R info(@PathVariable("id") Integer id){
        WithdrawalLogEntity withdrawalLog = withdrawalLogService.selectById(id);

        return R.ok().put("withdrawalLog", withdrawalLog);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("dev:withdrawallog:save")
    public R save(@RequestBody WithdrawalLogEntity withdrawalLog){
        withdrawalLogService.insert(withdrawalLog);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("dev:withdrawallog:update")
    public R update(@RequestBody WithdrawalLogEntity withdrawalLog){
        ValidatorUtils.validateEntity(withdrawalLog);
        withdrawalLogService.updateAllColumnById(withdrawalLog);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("dev:withdrawallog:delete")
    public R delete(@RequestBody Integer[] ids){
        withdrawalLogService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }
    
    @RequestMapping("/updateStatus")
    public R updateStatus(Integer id){
    	WithdrawalLogEntity withdrawalLog = withdrawalLogService.selectById(id);
    	withdrawalLog.setStatus("1");
    	withdrawalLogService.insertOrUpdate(withdrawalLog);
    	return R.ok("审核成功！");
    }

}
